package com.pacific.sign.biz.wrapper.aop;

import com.alibaba.fastjson.JSONObject;

import java.math.BigDecimal;
import java.util.List;

public class HcAopUtil {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	public static String getStringFromRequest(Object[] args){
		String req = "";
		for(Object arg:args){
			if(arg == null){
				req = req + "null,";
				continue;
			}else if(arg instanceof List ==true){
				req = req + JSONObject.toJSONString((List)arg);
			}else if( arg instanceof Enum){
				req = req + JSONObject.toJSONString(arg);
				return req;
			}else if(!(arg instanceof String)
					&& !(arg instanceof BigDecimal)
					&& !(arg instanceof Boolean)
					&& !(arg instanceof Integer) 
					&& (arg instanceof Object)){
				req = req+JSONObject.toJSONString(arg).toString()+",";
			}else{
				req = req+arg.toString()+",";
			}
		}
		return req;
	}
	
	public static String getStringFromResponse(Object arg){
		String rsp = "";
		if(arg == null){
			rsp = rsp + "null,";
			return rsp;
		}else if(arg instanceof List){
			rsp = rsp + JSONObject.toJSONString((List)arg);
			return rsp;
		}else if( arg instanceof Enum){
			rsp = rsp + JSONObject.toJSONString(arg);
			return rsp;
		}else if(!(arg instanceof String ) 
				&& !(arg instanceof BigDecimal) 
				&& !(arg instanceof Boolean)
				&& !(arg instanceof Integer )
				&& (arg instanceof Object)){
			rsp = rsp+JSONObject.toJSONString(arg).toString()+",";
		}else{
			rsp = rsp+arg.toString()+",";
		}
		return rsp;
	}
}
